{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "355a7c92-2113-4fef-a03e-046d71107b67",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/longest-palindrome"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "86cd1534-7a8e-4530-a661-32a0b6bdcf09",
   "metadata": {},
   "source": [
    "# 2023/01/24"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ed2c03a0-6dbe-41b4-b7dd-0e360a93c89d",
   "metadata": {},
   "source": [
    "Timeout \n",
    "\n",
    "```python\n",
    "from itertools import permutations \n",
    "\n",
    "class Solution:\n",
    "    def longestPalindrome(self, s: str) -> int:\n",
    "        #2023/01/24 07:08\n",
    "        result = \"\"\n",
    "        length = len(s)\n",
    "        while length > 0: \n",
    "            for possibility in permutations(list(s), length):\n",
    "                possibility = list(possibility)\n",
    "                if possibility == list(reversed(possibility)):\n",
    "                    if len(possibility) > len(result):\n",
    "                        result = \"\".join(possibility)\n",
    "                        length = 0\n",
    "                        break\n",
    "                #print(type(possibility))\n",
    "            length -= 1\n",
    "        return len(result)\n",
    "        #2023/01/24 07:17\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ee33ade6-fc73-4e2d-a998-34a343a63695",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
